import instacne from "../request";
import type { Ref } from "vue";

interface returnReason {
  keyword?: string | Ref<string>;
  pageNum?: number | Ref<number>;
  pageSize?: number | Ref<number>;
}

// 批量删除
interface returnReasonlist {
  ids: number[] | Ref<number[]> | number | Ref<number>;
  createTime?: string;
  id?: number;
  name?: string;
  sort?: number;
  status?: number;
  ischeck?: boolean;
}
interface returnReasonlisttwo {
  list: returnReasonlist[];
  pageNum: number;
  pageSize: number;
  total: number;
  totalPage: number;
}

// 分页查询全部退货原因
const getreturnReasonlist = (
  data?: returnReason
): Promise<returnReasonlisttwo> => {
  return instacne.get("/returnReason/list", {
    params: data,
  });
};

// 批量删除退货原因类型约束
// interface IreturnDeleteData {
//   ids: number[] | Ref<number[]> | number | Ref<number>;
// }
// 批量删除退货原因
const getreturnReasonlistdel = (data: returnReasonlist) => {
  return instacne.post(`/returnReason/delete?ids=${data}`);
};

// 添加退货原因
const getreturnReasonlistadd = (
  data: returnReasonlist
): Promise<returnReasonlist> => {
  return instacne.post("/returnReason/create", data);
};
// 修改退货原因
const getreturnReasonlistUpdate = (data: returnReasonlist) => {
  return instacne.post(`/returnReason/update/${data.id}`, data);
};
// 修改退货原因启用状态
const getreturnReasonlistUpdatestatus = (data: returnReasonlist) => {
  return instacne.post(
    `/returnReason/update/status?status=${data.status}&ids=${data.id}`
  );
};
export {
  getreturnReasonlist,
  getreturnReasonlistdel,
  getreturnReasonlistadd,
  getreturnReasonlistUpdate,
  getreturnReasonlistUpdatestatus,
};
export type { returnReasonlist };
